As shown in FIG. 15, a certain conventional angle sensor that uses a TMR element 1 includes a free layer 2, a pin layer 3, and a tunnel layer 4. The tunnel layer 4 is inserted between the free layer 2 and the pin layer 3.
In order to detect an external magnetic field, the free layer 2 includes a ferromagnet whose magnetization direction Ha rotates in accordance with an external magnetic field. The pin layer 3 includes a ferromagnet whose magnetization direction Hb is fixed in one direction. The tunnel layer 4 varies a tunnel current in accordance with a spin state prevailing between the free layer 2 and the pin layer 3.
The above-described TMR element 1 varies the resistance value of the tunnel layer 4 when the direction of the external magnetic field varies. More specifically, when the external magnetic field is given to the TMR element 1 in a direction parallel to the magnetization direction Hb of the pin layer 3, the resistance value of the tunnel layer 4 is minimized. When, on the other hand, the external magnetic field is given to the TMR element 1 in a direction antiparallel (that is, opposite) to the magnetization direction Hb of the pin layer 3, the resistance value of the tunnel layer 4 is maximized.
Consequently, the current flowing between the free layer 2 and pin layer 3 of the TMR element 1 (which is marked “OUTPUT” in FIG. 15) varies with the direction Y of the external magnetic field as indicated in the graph of FIG. 15. Hence, the direction Y of the external magnetic field can be measured when the current flowing between the free layer 2 and pin layer 3 of the TMR element 1 is monitored as the output of the TMR element 1.
Here, suppose that the angle between the direction Y of the external magnetic field and the magnetization direction Hb of the magnetization fixing layer is defined as the rotation angle (deg) of the external magnetic field. When the rotation angle is zero, the output of the TMR element 1 is maximized; when the rotation angle is 180 or −180 degrees, it is minimized. In other words, the relationship between the actual output of the TMR element 1 is the rotation angle (deg) of the external magnetic field is represented by a curve similar to a COS curve.
However, the actual output of the TMR element 1 (see a solid curve in the graph of FIG. 16) includes various components. Therefore, the relationship between the actual output of the TMR element 1 and the rotation angle of the external magnetic field cannot be represented by an ideal COS curve. Hence, the difference between the actual output of the TMR element 1 and the ideal COS curve becomes an error in the measurement of the rotation angle of the external magnetic field. This results in a decrease in the accuracy of rotation angle measurement.
In view of the circumstances, a magnetic sensor proposed, for instance, in Patent Literature 1 includes a bridge circuit, which is formed of first to fourth TMR elements to detect an external magnetic field, and a corrective TMR element, which corrects a measurement error.
In the above-mentioned magnetic sensor, the bridge circuit and the corrective TMR element are series-connected between a power supply and a ground to reduce an error in the measurement of the rotation angle of the external magnetic field; the error is included in the output of the bridge circuit.